<template>
  <div id="performance">
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="name" label="姓名" align="center">
        <template slot-scope="scope">
          <el-link type="primary" :underline='false' @click="student(scope.row.id)">{{scope.row.name}}</el-link>
        </template>
      </el-table-column>
     <el-table-column prop="tel" label="电话" align="center">
        <template slot-scope='scope'>
          <span v-if="scope.row.tel">{{scope.row.tel.substr(0,3)+"****"+scope.row.tel.substr(7)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="apply_type" label="申领类型" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.apply_type.title}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="package_id" label="学习班型" show-overflow-tooltip align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.package_id.title">{{scope.row.package_id.title}}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column prop="team_id" label="关联机构" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.team_id.title">{{scope.row.team_id.title}}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>

      <!-- 插入表格后面的信息 -->
      <slot></slot>

    </el-table>
    <el-row>
      <el-col :span="24" class="pagination">
        <!-- 翻页 -->
        <el-pagination class="fr" background @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="pages.page" :page-sizes="[10, 20, 30]" :page-size="10" layout="total, sizes, prev, pager, next"
          :total="pages.total">
        </el-pagination>
      </el-col>
    </el-row>
    <!-- 学员信息弹窗 -->
    <studentdialog @closetextDialog='closetextDialog' :isshowDialog='isshowStudent'></studentdialog>
  </div>
</template>

<script>
  //引入学员信息弹窗
  import studentdialog from './component/studentinfo'
  export default {
    data() {
      return {
        //是否学员信息显示弹窗
        isshowStudent: false,
        //表格数据
        tableData: [],
        //页码数据
        pages: {},
        studentID: ''
      }
    },
    methods: {
      //一页多少数据 翻页
      handleSizeChange(val) {
        this.$emit('handleSizeChange', val)
      },
      //翻页码
      handleCurrentChange(val) {
        this.$emit('handleCurrentChange', val)
      },
      //查看学员信息
      student(id) {
        console.log(id)
        //获取学员id
        this.studentID = id
        this.isshowStudent = true

      },
      //关闭
      closetextDialog() {
        this.isshowStudent = false
      }
    },
    components: {
      studentdialog
    },
    props: {
      //表格数据
      tabData: {
        type: Object,
        default: () => {
          return {}
        }
      }
    },
    mounted() {
      this.tableData = this.tabData.list
      this.pages = this.tabData.page
      console.log(' this.tableData', this.tableData)
    },
    watch: {
      tabData(val) {
        this.tableData = val.list
        this.pages = val.page

      }
    },
  }
</script>

<style scoped lang='scss'>
  #performance {
    margin-top: 30px;

    .pagination {
      margin-top: 20px;
    }
  }
</style>
